package com.hundsun.yr.universal.p2p.ui.activity.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;

import com.hundsun.yr.universal.library.base.BaseLazyFragment;
import com.hundsun.yr.universal.library.data.HSSharedPreferences;
import com.hundsun.mobile.zwgt.R;
import com.hundsun.yr.universal.p2p.config.Config;
import com.hundsun.yr.universal.p2p.ui.view.ProgressDailog;
import com.hundsun.yr.universal.p2p.view.base.BaseView;


/**
 * @Title: BaseFragment.java 
 * @Description: fragment基类
 * @date 2015-10-15 下午3:59:37 
 * @author:hejun.shen
 * @email:shenhj15971@hundsun.com 
 * @replace author:
 * @replace date:
 * @version V1.0   
 */
public abstract class BaseFragment extends BaseLazyFragment implements BaseView {
	
	
	/**加载进度条**/
	private ProgressDailog progressDailog=null;
	/**用户SharedPreferences**/
	protected HSSharedPreferences sharedPreferences=null;
	protected HSSharedPreferences mConfigSP=null;
	
	@Override
	public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
		sharedPreferences=new HSSharedPreferences(mContext, Config.SPPath.file_userLoginedInfo);
		mConfigSP = new HSSharedPreferences(mContext, Config.SPPath.file_configInfo);
		super.onViewCreated(view, savedInstanceState);

	}

	@Override
	public void showError(String msg,OnClickListener onClickListener) {
		toggleShowError(true, msg, onClickListener);
	}
    
    @Override
    public void showNetError(OnClickListener onClickListener) {
    	// TODO Auto-generated method stub
    	toggleNetworkError(true, onClickListener);
    }

    @Override
    public void showLoading(String msg) {
        toggleShowLoading(true, null);
    }

    @Override
    public void hideLoading() {
        toggleShowLoading(false, null);
    }
    
    @Override
	public void showEmpty(int drawableRes, String msg,OnClickListener onClickListener) {
		// TODO Auto-generated method stub
    	toggleShowEmpty(true, drawableRes, msg, onClickListener);
	}
    @Override
	public void showProgress(String msg) {
		// TODO Auto-generated method stub
    	if(progressDailog ==null){
    		progressDailog = new ProgressDailog(mContext, R.style.progress_dialog);
    	}
		if(TextUtils.isEmpty(msg)){
			progressDailog.showProgress();
		}else{
			progressDailog.showProgress(msg);
		}
		
	}
    
    @Override
	public void closeProgress() {
		// TODO Auto-generated method stub
		
		if(progressDailog!=null&&progressDailog.isShowing()){
			progressDailog.closeProgress();
		}
	}
    
}
